#![allow(dead_code)]
struct RangeLrn {}
impl RangeLrn {
    pub fn hello() {
        println!("Range learning!");
    }
}

#[cfg(test)]
mod tests {

    #[test]
    /// start..end 语法是 Range
    fn test_basic() {
        assert_eq!((3..6), std::ops::Range { start: 3, end: 6 });
        assert_eq!(3 + 4 + 5, (3..6).sum());

        let arr = [0, 1, 2, 3, 4];
        assert_eq!(arr[..], [0, 1, 2, 3, 4]);
        assert_eq!(arr[..3], [0, 1, 2]);
        assert_eq!(arr[..=3], [0, 1, 2, 3]);
        assert_eq!(arr[1..], [1, 2, 3, 4]);
        assert_eq!(arr[1..3], [1, 2]); // 这是 `Range`
        assert_eq!(arr[1..=3], [1, 2, 3]);
    }

    #[test]
    fn test_contains() {
        assert!((3..5).contains(&3));
        assert!(!(3..5).contains(&2));
    }

    #[test]
    fn test_is_empty() {
        assert!((3..3).is_empty());
        assert!(!(3..5).is_empty());
    }

    #[test]
    fn test_max() {
        let vec = [1, 23, 4, 567, 34];
        let max = vec.iter().max();
        println!("{:?}", max.unwrap());
    }

    #[test]
    fn test_range() {
        let range = 1..5;

        assert_eq!(1, range.start);
        assert!(range.contains(&3));
        assert!(!range.is_empty());
    }
}
